package com.aitaoxue.palx.viewpagefragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.aitaoxue.palx.R;
import com.aitaoxue.palx.adapter.ViewPageFragmentAdapter;
import com.aitaoxue.palx.base.BaseListFragment;
import com.aitaoxue.palx.base.BaseViewPagerFragment;
import com.aitaoxue.palx.bean.Course;
import com.aitaoxue.palx.fragment.CourseFragment;

public class CourseViewPagerFragment extends BaseViewPagerFragment {

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return inflater.inflate(R.layout.course_viewpager_fragment, null);
	}

	public static CourseViewPagerFragment newInstance() {
		return new CourseViewPagerFragment();
	}

	@Override
	public void onClick(View arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void initView(View view) {
		// TODO Auto-generated method stub

	}

	@Override
	public void initData() {
		// TODO Auto-generated method stub

	}

	@Override
	protected void onSetupTabAdapter(ViewPageFragmentAdapter adapter) {
		String[] title = getResources().getStringArray(
				R.array.course_viewpage_arrays);
		adapter.addTab(title[0], "not", CourseFragment.class,
				getBundle(Course.NOT_DEAL));
		adapter.addTab(title[1], "ing", CourseFragment.class,
				getBundle(Course.DEALING));
		adapter.addTab(title[2], "ed", CourseFragment.class,
				getBundle(Course.DEALED));
		// adapter.addTab("test", "test", ErrorBookListFragment.class, null);
	}

	private Bundle getBundle(String courseType) {
		Bundle bundle = new Bundle();
		bundle.putString(BaseListFragment.BUNDLE_COURSE_TYPE, courseType);
		return bundle;
	}

	public void refreshNotDeal() {
		mTabsAdapter.changeRefreshFlag(ViewPageFragmentAdapter.NOT_DEAL);
		mTabsAdapter.notifyDataSetChanged();
	}

	public void refreshDealing() {
		mTabsAdapter.changeRefreshFlag(ViewPageFragmentAdapter.DEALING);
		mTabsAdapter.notifyDataSetChanged();
	}

	public void refreshDealed() {
		mTabsAdapter.changeRefreshFlag(ViewPageFragmentAdapter.DEALED);
		mTabsAdapter.notifyDataSetChanged();
	}
	
}





